package com.drug.web.controller.wms;

import com.drug.common.annotation.Log;
import com.drug.common.core.controller.BaseController;
import com.drug.common.core.domain.AjaxResult;
import com.drug.common.core.page.TableDataInfo;
import com.drug.common.enums.BusinessType;
import com.drug.common.utils.poi.ExcelUtil;
import com.drug.wms.domain.BusBankAccInfo;
import com.drug.wms.service.IBusBankAccInfoService;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 银行信息Controller
 *
 * @author ruoyi
 * @date 2021-11-10
 */
@Api("银行卡信息管理")
@RestController
@RequestMapping("/bankAcc/info")
public class BusBankAccInfoController extends BaseController {
    @Autowired
    private IBusBankAccInfoService busBankAccInfoService;

    /**
     * 查询银行信息列表
     */
    @ApiOperation("查询银行信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "银行主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankNo", value = "银行编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankName", value = "银行全名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusBankAccInfo busBankAccInfo) {
        startPage();
        PageHelper.orderBy("create_time desc");
        List<BusBankAccInfo> list = busBankAccInfoService.selectBusBankAccInfoList(busBankAccInfo);
        return getDataTable(list);
    }

    /**
     * 导出银行信息列表
     */
    @ApiOperation("导出银行信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "银行主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankNo", value = "银行编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankName", value = "银行全名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "银行信息" , businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusBankAccInfo busBankAccInfo) {
        List<BusBankAccInfo> list = busBankAccInfoService.selectBusBankAccInfoList(busBankAccInfo);
        ExcelUtil<BusBankAccInfo> util = new ExcelUtil<BusBankAccInfo>(BusBankAccInfo.class);
        return util.exportExcel(list, "银行信息数据");
    }

    /**
     * 获取银行信息详细信息
     */
    @ApiOperation("获取银行信息详细信息")
    @ApiImplicitParam(name = "id", value = "银行id", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class)
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(busBankAccInfoService.selectBusBankAccInfoById(id));
    }

    /**
     * 新增银行信息
     */
    @ApiOperation("新增银行信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "银行主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankNo", value = "银行编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankName", value = "银行全名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "银行信息" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusBankAccInfo busBankAccInfo) {
        return toAjax(busBankAccInfoService.insertBusBankAccInfo(busBankAccInfo));
    }

    /**
     * 修改银行信息
     */
    @ApiOperation("修改银行信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "银行主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankNo", value = "银行编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankName", value = "银行全名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "银行信息" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusBankAccInfo busBankAccInfo) {
        return toAjax(busBankAccInfoService.updateBusBankAccInfo(busBankAccInfo));
    }

    /**
     * 删除银行信息
     */
    @ApiOperation("删除银行信息")
    @ApiImplicitParam(name = "ids", value = "银行ids", required = true,allowMultiple = true, dataType = "String", paramType = "path", dataTypeClass = String.class)
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "银行信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(busBankAccInfoService.deleteBusBankAccInfoByIds(ids));
    }
}
